const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const GroupSchema = new Schema({
    name: {
        type: String,
        index: true,
        unique: true,
        trim: true
    },
    create_time: {
        type: Date,
        default: Date.now
    },
    avatar: String,
    creator: Schema.Types.ObjectId,
    members: [{
        type: Schema.Types.ObjectId,
        ref: 'User'
    }]
})


const Group = mongoose.model('Group', GroupSchema);

module.exports = Group;